﻿<UserControl x:Class="LookupControl.SilverCrmLookup"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
			 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
			 Width="150"
			 Height="20"
			 GotFocus="StackPanel_GotFocus"
			 IsTabStop="True"
			 KeyDown="LayoutRoot_KeyDown"
			 Loaded="UserControl_Loaded"
			 LostFocus="ctrlLookup_LostFocus"
			 UseLayoutRounding="True"
			 mc:Ignorable="d">
	<Grid x:Name="LayoutRoot" Background="White">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*" />
			<ColumnDefinition Width="21" />
		</Grid.ColumnDefinitions>
		<Grid.Resources>
			<Style x:Key="HyperlinkButtonStyle" TargetType="HyperlinkButton">
				<Setter Property="Foreground" Value="#FF73A9D8" />
				<Setter Property="Padding" Value="2,0,2,0" />
				<Setter Property="Cursor" Value="Hand" />
				<Setter Property="HorizontalContentAlignment" Value="Left" />
				<Setter Property="VerticalContentAlignment" Value="Top" />
				<Setter Property="Background" Value="Transparent" />
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="HyperlinkButton">
							<Grid Background="{TemplateBinding Background}" Cursor="{TemplateBinding Cursor}">
								<VisualStateManager.VisualStateGroups>
									<VisualStateGroup x:Name="CommonStates">
										<VisualState x:Name="Normal" />
										<VisualState x:Name="MouseOver" />
										<VisualState x:Name="Pressed" />
										<VisualState x:Name="Disabled">
											<Storyboard>
												<ObjectAnimationUsingKeyFrames Duration="0"
																			   Storyboard.TargetName="DisabledOverlay"
																			   Storyboard.TargetProperty="Visibility">
													<DiscreteObjectKeyFrame KeyTime="0">
														<DiscreteObjectKeyFrame.Value>
															<Visibility>Visible</Visibility>
														</DiscreteObjectKeyFrame.Value>
													</DiscreteObjectKeyFrame>
												</ObjectAnimationUsingKeyFrames>
											</Storyboard>
										</VisualState>
									</VisualStateGroup>
									<VisualStateGroup x:Name="FocusStates">
										<VisualState x:Name="Focused">
											<Storyboard>
												<DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
													<SplineDoubleKeyFrame KeyTime="0" Value="1" />
												</DoubleAnimationUsingKeyFrames>
											</Storyboard>
										</VisualState>
										<VisualState x:Name="Unfocused" />
									</VisualStateGroup>
								</VisualStateManager.VisualStateGroups>
								<TextBlock x:Name="UnderlineTextBlock"
										   Margin="{TemplateBinding Padding}"
										   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
										   VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
										   Text="{TemplateBinding Content}"
										   TextDecorations="Underline" />
								<TextBlock x:Name="DisabledOverlay"
										   Margin="{TemplateBinding Padding}"
										   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
										   VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
										   Canvas.ZIndex="1"
										   Foreground="#FFAAAAAA"
										   Text="{TemplateBinding Content}"
										   Visibility="Collapsed" />
								<ContentPresenter x:Name="contentPresenter"
												  Margin="{TemplateBinding Padding}"
												  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
												  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
												  Content="{TemplateBinding Content}"
												  ContentTemplate="{TemplateBinding ContentTemplate}" />
								<Rectangle x:Name="FocusVisualElement"
										   IsHitTestVisible="false"
										   Opacity="0"
										   Stroke="#FF6DBDD1"
										   StrokeThickness="1" />
							</Grid>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
			<DataTemplate x:Key="AutoItemTemplate">
				<StackPanel Orientation="Horizontal">
					<Image x:Name="autoIcon"
						   Source="{Binding Icon}"
						   Stretch="None" />
					<Rectangle Width="5" />
					<TextBlock x:Name="autoTextBlock"
							   Text="{Binding Name}"
							   ToolTipService.ToolTip="{Binding Text,
																RelativeSource={RelativeSource Self}}" />
				</StackPanel>
			</DataTemplate>
			<Style x:Key="AutoTextStyle" TargetType="TextBox">
				<Style.Setters>
					<Setter Property="FontSize" Value="11" />
					<Setter Property="VerticalAlignment" Value="Center" />
				</Style.Setters>
			</Style>
		</Grid.Resources>
		<Border Name="border"
				BorderBrush="LightGray"
				BorderThickness="1">
			<Grid x:Name="innerGrid" Grid.Column="0">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" MaxWidth="16" />
					<ColumnDefinition Width="*" />
					<ColumnDefinition x:Name="domainCol" Width="0" />
				</Grid.ColumnDefinitions>
				<StackPanel Grid.Column="0" VerticalAlignment="Center">
					<Image Name="icoLookupIcon"
						   Cursor="Hand"
						   Stretch="None" />
				</StackPanel>
				<StackPanel Name="pnlContent"
							Grid.Column="1"
							HorizontalAlignment="Left"
							Orientation="Horizontal">
					<HyperlinkButton Name="lnkButton"
									 Width="Auto"
									 VerticalAlignment="Center"
									 Foreground="Blue"
									 IsTabStop="False"
									 Padding="2,0,0,0"
									 Style="{StaticResource HyperlinkButtonStyle}"
									 ToolTipService.ToolTip="{Binding Content,
																	  RelativeSource={RelativeSource Self}}" />
					<sdk:AutoCompleteBox Name="autoCompleteBox"
										 Width="Auto"
										 BorderThickness="0"
										 DropDownClosed="autoCompleteBox_DropDownClosed"
										 IsTextCompletionEnabled="False"
										 ItemTemplate="{StaticResource AutoItemTemplate}"
										 KeyDown="autoCompleteBox_KeyDown"
										 LostFocus="autoCompleteBox_LostFocus"
										 MaxDropDownHeight="250"
										 MinimumPrefixLength="1"
										 MouseLeftButtonDown="autoCompleteBox_MouseLeftButtonDown"
										 Populating="autoCompleteBox_Populating"
										 SelectedItem="{Binding AutoItem}"
										 TextBoxStyle="{StaticResource AutoTextStyle}"
										 ValueMemberBinding="{Binding Name}"
										 Visibility="Collapsed" />
				</StackPanel>
				<StackPanel Grid.Column="2" Orientation="Horizontal">
					<toolkit:DomainUpDown Name="domainUpDown1"
										  Width="16"
										  Height="20"
										  HorizontalAlignment="Left"
										  VerticalAlignment="Center"
										  BorderThickness="0"
										  IsEditable="False"
										  ValueChanged="domainUpDown1_ValueChanged" />
				</StackPanel>
			</Grid>
		</Border>
		<StackPanel Grid.Column="1" Orientation="Horizontal">
			<Image Name="btnLookupButton"
				   Cursor="Hand"
				   Source="/LookupControl;component/Images/btn_lookup_resolving.png"
				   Stretch="Uniform" />
		</StackPanel>
	</Grid>
</UserControl>